#pragma once

#include "GdiplusHelper.h"
#include "ControlExt.h"

// CPictureEdit
#define NOUSE -1
#include <vector>
using namespace std;


class CPictureEdit : public CEdit, public CControlExt
{
public:
	CPictureEdit();
	virtual ~CPictureEdit();

protected:
	void DrawBackground();
	void DrawControl();
	void DrawString(CDC& dc);

protected:
	DECLARE_MESSAGE_MAP()

private:
	CDC* m_pMemDestDC;
	CBitmap* m_pMemDestBitmap;

	int m_nCurPos;
	vector<RectF> m_vecRect;

	void GetCharPos();
	void SetCaret(CPoint point);
	void MoveCaret(int nPos);
	void DeleteChar(int nPos);
	POINT GetDefaultPos();

public:
	afx_msg void OnPaint();
	afx_msg void OnEnChange();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnSetFocus(CWnd* pOldWnd);
	virtual BOOL PreTranslateMessage(MSG* pMsg);
};
